package com.zhiche.lisa.bms.controller.fee;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.google.common.collect.Lists;
import com.lisa.syslog.model.publics.PublicLog;
import com.zhiche.lisa.bms.controller.utils.ToolLogUtils;
import com.zhiche.lisa.bms.dao.model.contract.ContractFinalpay;
import com.zhiche.lisa.bms.dao.model.fee.FeePayable;
import com.zhiche.lisa.bms.dao.model.fee.FeePayableTemp;
import com.zhiche.lisa.bms.dao.model.interfacelog.InterfaceLog;
import com.zhiche.lisa.bms.dao.model.price.PricePurchase;
import com.zhiche.lisa.bms.pojo.dto.fee.ShipParamDTO;
import com.zhiche.lisa.bms.pojo.dto.fee.TmsReleaseDto;
import com.zhiche.lisa.bms.pojo.dto.util.OtmServiceResult;
import com.zhiche.lisa.bms.pojo.vo.common.CommonVO;
import com.zhiche.lisa.bms.pojo.vo.common.FeePermissCommonVO;
import com.zhiche.lisa.bms.pojo.vo.fee.FeePayableHeaderVO;
import com.zhiche.lisa.bms.service.fee.FeePayableService;
import com.zhiche.lisa.bms.service.fee.FeePayableTempService;
import com.zhiche.lisa.bms.service.utils.InterfaceLogUtil;
import com.zhiche.lisa.bms.service.utils.OtmUtil;
import com.zhiche.lisa.bms.service.utils.WmsUtil;
import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 应付账款 前端控制器
 * </p>
 *
 * @author zhangkun
 * @since 2018-09-03
 */
@RestController
@RequestMapping("/feePayable")
@Api(value = "feePayable", description = "应付账款", tags = "应付账款")
public class FeePayableController {
    public Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private FeePayableService feePayableService;

    @Autowired
    private InterfaceLogUtil interfaceLogUtil;

    @Autowired
    private FeePayableTempService feePayableTempService;

    @Autowired
    private WmsUtil wmsUtil;

    @Autowired
    private ToolLogUtils toolLogUtils;

    @PostMapping("/queryFeePayablePage")
    @ApiOperation(value = "/queryFeePayableApi", notes = "查询应收付款", response = RestfulResponse.class)
    public RestfulResponse<Page<FeePayable>> queryFeePayablePage(@RequestBody Page page) {
        logger.info("controller:FeePayable/queryFeePayablePage data:{}", page);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            Page feePayable = feePayableService.queryFeePayablePage(page);
            result.setData(feePayable);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @PostMapping("/feePayableList")
    @ApiOperation(value = "/feePayableList", notes = "查询应收付款", response = RestfulResponse.class)
    public RestfulResponse<List<FeePayable>> feePayableList(@RequestBody Map<String, Object> condition) {
        logger.info("controller:FeePayable/feePayableList data:{}", condition);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            List<FeePayable> feePayable = feePayableService.selectFeePayableList(condition);
            result.setData(feePayable);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @GetMapping("/getFeePayable/{id}")
    @ApiOperation(value = "/getFeePayable", notes = "查询应收付款", response = RestfulResponse.class)
    public RestfulResponse<FeePayable> getFeePayable(@PathVariable("id") Long id) {
        logger.info("controller:FeePayable/getFeePayable data:{}", id);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            FeePayable feePayable = feePayableService.queryFeePayableById(id);
            result.setData(feePayable);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @PostMapping("/queryFeePayableSumHeader")
    @ApiOperation(value = "/queryFeePayableApi", notes = "查询应收付款总和信息", response = RestfulResponse.class)
    public RestfulResponse<FeePayableHeaderVO> queryFeePayablePage(@RequestBody CommonVO commonVO) {
        logger.info("controller:FeePayable/queryFeePayableSumHeader data:{}", commonVO);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            FeePayableHeaderVO feePayable = feePayableService.queryFeePayableSumHeader(Arrays.asList(commonVO.getIds()));
            result.setData(feePayable);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @PostMapping("/queryFeePayableByIds")
    @ApiOperation(value = "/queryFeePayableApi", notes = "查询指定应收付款", response = RestfulResponse.class)
    public RestfulResponse<List<FeePayable>> queryFeePayableByIds(@RequestBody CommonVO commonVO) {
        logger.info("controller:FeePayable/queryFeePayableByIds data:{}", commonVO);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            List<FeePayable> feePayable = feePayableService.queryFeePayableByIds(Arrays.asList(commonVO.getIds()));
            result.setData(feePayable);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    /**
     * 主要是发运接口
     *
     * @param shipParamDTO
     * @return
     */
    @PostMapping("/createFeePayable")
    @ApiOperation(value = "/创建应付账单数据", notes = "创建应付账单数据", response = RestfulResponse.class)
    public RestfulResponse<String> createFeePayable(@RequestBody ShipParamDTO shipParamDTO) {
        logger.info("FeePayableController.createFeePayable data:{}", shipParamDTO);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        InterfaceLog interfaceLog = new InterfaceLog();
        PublicLog publicLog = new PublicLog();
        try {
            publicLog = toolLogUtils.addToolSystemLog("lisa-tms", "/feePayable/createFeePayable",
                    shipParamDTO.getOrderReleaseId(), shipParamDTO, 0, null);
            interfaceLogUtil.setCalleeCommonLog(interfaceLog, shipParamDTO, "/feePayable/createFeePayable");
            FeePayableTemp feePayableTemp = new FeePayableTemp();
            BeanUtils.copyProperties(shipParamDTO, feePayableTemp);
            if (StringUtils.isNotBlank(shipParamDTO.getFleetId())) {
                feePayableTemp.setFleetId(Long.parseLong(shipParamDTO.getFleetId()));
            }
            feePayableTempService.insert(feePayableTemp);
            toolLogUtils.addSuccessSystemLog(publicLog);
            //String createFeePayableMsg = feePayableService.synchroCreateFeePayable(shipParamDTO);
            //if (Strings.isNullOrEmpty(createFeePayableMsg)) {
            //    interfaceLogUtil.setSuccessLog(interfaceLog);
            //} else {
            //    interfaceLogUtil.setErrorLog(interfaceLog, createFeePayableMsg);
            //    result.setCode(-1);
            //    result.setMessage(createFeePayableMsg);
            //}
        } catch (BaseException e) {
            interfaceLogUtil.setErrorLog(interfaceLog, e.getMessage());
            toolLogUtils.addErrorSystmeLog(publicLog, e.getMessage());
            logger.error("FeePayableController.createFeePayable error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            interfaceLogUtil.setErrorLog(interfaceLog, e.getMessage());
            toolLogUtils.addErrorSystmeLog(publicLog, e.getMessage());
            logger.error("FeePayableController.createFeePayable error: {}", e);
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        // 保存日志
        interfaceLogUtil.setCallPartySuccessLog(interfaceLog, result);
        interfaceLogUtil.saveInterfaceLog(interfaceLog);
        logger.info("FeePayableController.createFeePayable end");
        return result;
    }

    @PostMapping("/updateFeePayablePrice")
    @ApiOperation(value = "/更新价格", notes = "更新价格", response = RestfulResponse.class)
    public RestfulResponse<List<String>> updateFeePayablePrice(@RequestBody CommonVO commonVO) {
        logger.info("FeePayableController.updateFeePayablePrice data:{}", commonVO);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            List<String> msg = new ArrayList<>();
            for (Long id :
                    commonVO.getIds()) {
                try {
                    feePayableService.updateFeePayablePrice(id);
                    msg.add("更新价格::成功");
                } catch (BaseException e) {
                    msg.add("更新价格::" + e.getMessage());
                    result.setCode(-2);
                    result.setMessage("失败");
                } catch (Exception e) {
                    msg.add("更新价格::更新失败");
                    result.setCode(-2);
                    result.setMessage("失败");
                }
            }
            result.setData(msg);
        } catch (BaseException e) {
            logger.error("FeePayableController.updateFeePayablePrice error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        logger.info("FeePayableController.updateFeePayablePrice end");
        return result;
    }

    @PostMapping("/insertFeePayable")
    @ApiOperation(value = "insertPayableApi", notes = "新增应收账款", response = RestfulResponse.class)
    public RestfulResponse<String> insertFeePayable(@RequestBody PricePurchase pricePurchase, @RequestHeader("Authorization") String token) {
        logger.info("controller:/FeePayable/insertFeePayable data : {}", pricePurchase, token);
        RestfulResponse<String> result = new RestfulResponse<>(0, "成功", null);
        try {
            feePayableService.insertFeePayable(pricePurchase, token);
        } catch (BaseException e) {
            logger.error("FeePayableController.insertFeePayable error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.insertFeePayable error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    @GetMapping("/getContractFinalpayList/{id}")
    @ApiOperation(value = "getContractFinalpayList", notes = "根据id号获指定应付账款对应合同的油卡明细", response = RestfulResponse.class)
    public RestfulResponse<List<ContractFinalpay>> getContractFinalpayList(@PathVariable("id") Long id) {
        logger.info("controller:/FeePayable/getContractFinalpayList data : {}", id);
        RestfulResponse<List<ContractFinalpay>> result = new RestfulResponse<>(0, "成功", null);
        try {
            result.setData(feePayableService.getContractFinalpayList(id));
        } catch (BaseException e) {
            logger.error("FeePayableController.getContractFinalpayList error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.getContractFinalpayList error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    @PostMapping("/getColumnSum")
    @ApiOperation(value = "getColumnSum", notes = "或取列的总和", response = RestfulResponse.class)
    public RestfulResponse<Object> getContractFinalpayList(@RequestBody Map<String, Object> condition) {
        logger.info("controller:/FeePayable/getColumnSum data : {}", condition);
        RestfulResponse<Object> result = new RestfulResponse<>(0, "成功", null);
        try {
            Object columnName = condition.get("columnName");
            if (condition == null || columnName == null) {
                throw new BaseException("请选择查询数据");
            }
            condition.remove("columnName");
            result.setData(feePayableService.getColumnSum(columnName.toString(), condition));
        } catch (BaseException e) {
            logger.error("FeePayableController.getColumnSum error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.getColumnSum error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    @PostMapping("/updateFeePayableByRouteMode")
    @ApiOperation(value = "updateFeePayableByRouteMode", notes = "更新指定应付账单的发运状态", response = RestfulResponse.class)
    public RestfulResponse<Object> updateFeePayableByRouteMode(@RequestBody CommonVO<Long> ids) {
        logger.info("controller:/FeePayable/updateFeePayableByRouteMode data : {}", ids);
        RestfulResponse<Object> result = new RestfulResponse<>(0, "成功", null);
        try {
            result.setData(feePayableService.updateAppointFeePayableByRouteMode(ids.getEntityParams()));
        } catch (BaseException e) {
            logger.error("FeePayableController.updateFeePayableByRouteMode error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.updateFeePayableByRouteMode error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    /**
     * 根据条件获取对应的id集合
     *
     * @param page
     * @return
     */
    @PostMapping("/queryFeePayableIdList")
    @ApiOperation(value = "/queryFeePayableIdList", notes = "查询应付账款id", response = RestfulResponse.class)
    public RestfulResponse<List<Long>> queryFeePayableIdList(@RequestBody Page<FeePayable> page) {
        logger.info("FeePayableController.queryFeePayableIdList data:{}", page);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            result.setData(feePayableService.queryFeePayableIdList(page));
        } catch (Exception e) {
            logger.error("FeePayableController.queryFeePayableIdList error: {}", e.getMessage());
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @PostMapping("/queryFeePayablePageByIds")
    @ApiOperation(value = "/queryFeePayablePageByIds", notes = "查询指定应收付款-分页", response = RestfulResponse.class)
    public RestfulResponse<Page<FeePayable>> queryFeePayablePageByIds(@RequestBody Page<CommonVO> page) {
        logger.info("FeePayableController.queryFeePayablePageByIds data:{}", page);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            result.setData(feePayableService.queryFeePayablePageByIds(page));
        } catch (Exception e) {
            logger.error("FeePayableController.queryFeePayablePageByIds error: {}", e.getMessage());
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @PostMapping("/updateCiamsId")
    @ApiOperation(value = "/updateCiamsId", notes = "更新客户", response = RestfulResponse.class)
    public RestfulResponse<String> updateCiamsId(@RequestBody Map<String, Object> condition) {
        logger.info("FeePayableController.updateCiamsId data:{}", condition);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            feePayableService.updateCiamsId(condition);
        } catch (BaseException e) {
            logger.error("FeePayableController.updateCiamsId error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.updateCiamsId error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    @PostMapping("/updatePurchasePrice")
    @ApiOperation(value = "/updatePurchasePrice", notes = "重新推送价格", response = RestfulResponse.class)
    public RestfulResponse<String> updatePurchasePrice(@RequestBody List<Long> feeIds) {
        logger.info("FeePayableController.updatePurchasePrice data:{}", feeIds);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            List<FeePayable> feePayables = feePayableService.selectBatchIds(feeIds);
            if (!CollectionUtils.isEmpty(feePayables)) {
                feePayables.forEach(feePayable -> {
                    feePayableService.updateExtPurchasePriceByItemUidNoTenant(feePayable);
                });
            } else {
                throw new BaseException("无匹配对应付账款");
            }
        } catch (BaseException e) {
            logger.error("FeePayableController.updatePurchasePrice error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.updatePurchasePrice error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }


    @PostMapping("/getWmsDateByOrderCode")
    @ApiOperation(value = "/getWmsDateByOrderCode", notes = "获取订单数据", response = RestfulResponse.class)
    public RestfulResponse<String> getWmsDateByOrderCode(@RequestBody FeePayable feePayable) {
        logger.info("FeePayableController.getWmsDateByOrderCode paramJson:{}", feePayable);
        RestfulResponse result = new RestfulResponse(0, "获取订单数据成功", null);
        try {
            if (feePayable == null || StringUtils.isBlank(feePayable.getOrderCode())) {
                throw new BaseException("请输入指令号");
            }
            String[] paramArray = feePayable.getOrderCode().trim().replace(" ", "").split(",|;|\n");
            String paramJson = StringUtils.join(paramArray, ",");
            wmsUtil.getWmsDateByOrderCode(paramJson);
        } catch (BaseException e) {
            logger.error("FeePayableController.getWmsDateByOrderCode error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.getWmsDateByOrderCode error: {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    /**
     * 针对临时车队的数据同一个指令号下未回单不可出账
     *
     * @param idList
     * @return
     */
    @PostMapping(value = "/queryPermissOrderCode")
    @ApiOperation(value = "针对临时车队的数据同一个指令号下未回单不可出账", notes = "针对临时车队的数据同一个指令号下未回单不可出账", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponses({@ApiResponse(code = 0, message = "success"), @ApiResponse(code = -1, message = "系统异常")})
    public RestfulResponse<FeePermissCommonVO> queryPermissOrderCode(@RequestBody CommonVO<Long> idList) {
        logger.info("FeePayableController.queryPermissOrderCode param {} ", idList);
        RestfulResponse<FeePermissCommonVO> restful = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            if (idList.getIds() == null || idList.getIds().length <= 0) {
                throw new BaseException("请选择数据!");
            }
            FeePermissCommonVO commonVO = feePayableService.queryPermissOrderCode(idList.getIds());
            if (commonVO != null && !CollectionUtils.isEmpty(commonVO.getOrderCodeList())) {
                restful.setCode(-3);
                restful.setData(commonVO);
                restful.setMessage("操作失败");
            }
        } catch (BaseException e) {
            logger.error("FeePayableController.queryPermissOrderCode ERROR: {}", e.getMessage());
            restful = new RestfulResponse(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.queryPermissOrderCode ERROR: {}", e.getMessage());
            restful = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return restful;
    }


    @Autowired
    OtmUtil otmUtil;

    /**
     * 批量获取otm标准价
     *
     * @param waybillDtlIdList
     * @return
     */
    @PostMapping(value = "/getOtmStandPriceNoLog")
    public RestfulResponse<Object> getOtmStandPriceNoLog(@RequestBody List<String> waybillDtlIdList) {
        RestfulResponse<Object> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            if (CollectionUtils.isNotEmpty(waybillDtlIdList)) {
                List<JSONObject> objList = Lists.newArrayList();
                waybillDtlIdList.forEach(waybillDtlId -> {
                    JSONObject obj = new JSONObject();
                    OtmServiceResult otmResult = otmUtil.getStdPriceNoInterfaceLog(waybillDtlId);
                    obj.put("OR号", waybillDtlId);
                    if (StringUtils.isNotBlank(otmResult.getData())) {
                        Map<String, Object> data = JSONObject.parseObject(otmResult.getData(), Map.class);
                        obj.put("标准价", data);
                    } else {
                        obj.put("标准价", otmResult.getMessage());
                    }
                    objList.add(obj);
                });
                result.setData(objList);
            }
        } catch (Exception e) {
            logger.error("FeePayableController.queryPermissOrderCode ERROR: {}", e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 更新账款信息和价格以及预付账单信息
     *
     * @param tmsReleaseDto
     * @return
     */
    @PostMapping(value = "/updateFeePayableForTms")
    public RestfulResponse<Object> updateFeePayableForTms(@RequestBody TmsReleaseDto tmsReleaseDto) {
        logger.info("FeePayableController.updateFeePayableForTms param: {}", tmsReleaseDto);
        RestfulResponse<Object> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        PublicLog publicLog = new PublicLog();
        try {
            publicLog = toolLogUtils.addToolSystemLog("lisa-tms", "/feePayable/updateFeePayableForTms",
                    tmsReleaseDto.getReleaseGid(), tmsReleaseDto, 0, null);
            // 更新
            feePayableService.updateFeePayableForTms(tmsReleaseDto);
            toolLogUtils.addSuccessSystemLog(publicLog);
        } catch (BaseException e) {
            logger.error("FeePayableController.updateFeePayableForTms ERROR: {}", e.getMessage());
            toolLogUtils.addErrorSystmeLog(publicLog, e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.updateFeePayableForTms ERROR: {}", e.getMessage());
            toolLogUtils.addErrorSystmeLog(publicLog, e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 获取人送慧运车计价
     *
     * @param sysWaybillList
     * @return
     */
    @PostMapping(value = "/getHuiyunChePrice")
    public RestfulResponse<Object> getHuiyunChePrice(@RequestBody List<String> sysWaybillList) {
        RestfulResponse<Object> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            result.setData(feePayableService.getHuiyunchePrice(sysWaybillList));
        } catch (Exception e) {
            logger.error("FeePayableController.getHuiyunChePrice ERROR: {}", e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 更新慧运车数据的信息
     *
     * @param feeIdList
     * @return
     */
    @PostMapping(value = "/updateHycData")
    public RestfulResponse<Object> updateHycData(@RequestBody List<Long> feeIdList) {
        RestfulResponse<Object> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            feePayableService.updateHycData(feeIdList);
        } catch (BaseException e) {
            logger.error("FeePayableController.updateHycData ERROR: {}", e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            logger.error("FeePayableController.updateHycData ERROR: {}", e.getMessage());
            result = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }
}